﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeBulid.Winform.Unit
{
    /// <summary>
    /// 生成文件
    /// </summary>
    public class CreateFile
    {

        public static void Create(string filePath, string content)
        {
            var path = Path.GetDirectoryName(filePath);
            if (string.IsNullOrEmpty(path)) return;

            if (!System.IO.Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            if (!System.IO.File.Exists(filePath))
            {
                var stream = System.IO.File.Create(filePath);
                stream.Close();
                stream.Dispose();
            }

            File.WriteAllText(filePath, content);
        }
    }
}
